home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2001 May / SGI Freeware 2001 May - Disc 3.iso / dist / fw_openssl.idb / usr / freeware / catman / p_man / cat3 / BN_add.Z / BN_add
Text File  |  2001-01-10  |  5KB  |  133 lines

  1.  
  2.  
  3.  
  4.      BBBBNNNN____aaaadddddddd((((3333))))            22224444////FFFFeeeebbbb////2222000000000000    ((((0000....9999....6666))))             BBBBNNNN____aaaadddddddd((((3333))))
  5.  
  6.  
  7.  
  8.      NNNNAAAAMMMMEEEE
  9.       BN_add, BN_sub, BN_mul, BN_div, BN_sqr, BN_mod, BN_mod_mul,
  10.       BN_exp, BN_mod_exp, BN_gcd - arithmetic operations on
  11.       BIGNUMs
  12.  
  13.      SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS
  14.        #include <openssl/bn.h>
  15.  
  16.        int BN_add(BIGNUM *r, const BIGNUM *a, const    BIGNUM *b);
  17.  
  18.        int BN_sub(BIGNUM *r, const BIGNUM *a, const    BIGNUM *b);
  19.  
  20.        int BN_mul(BIGNUM *r, BIGNUM    *a, BIGNUM *b, BN_CTX *ctx);
  21.  
  22.        int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *a,    const BIGNUM *d,
  23.            BN_CTX *ctx);
  24.  
  25.        int BN_sqr(BIGNUM *r, BIGNUM    *a, BN_CTX *ctx);
  26.  
  27.        int BN_mod(BIGNUM *rem, const BIGNUM    *a, const BIGNUM *m, BN_CTX *ctx);
  28.  
  29.        int BN_mod_mul(BIGNUM *ret, BIGNUM *a, BIGNUM *b, const BIGNUM *m,
  30.            BN_CTX *ctx);
  31.  
  32.        int BN_exp(BIGNUM *r, BIGNUM    *a, BIGNUM *p, BN_CTX *ctx);
  33.  
  34.        int BN_mod_exp(BIGNUM *r, BIGNUM *a,    const BIGNUM *p,
  35.            const BIGNUM    *m, BN_CTX *ctx);
  36.  
  37.        int BN_gcd(BIGNUM *r, BIGNUM    *a, BIGNUM *b, BN_CTX *ctx);
  38.  
  39.  
  40.      DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  41.       _B_N__a_d_d() adds    aaaa and bbbb    and places the result in rrrr (r=a+b).  rrrr
  42.       may be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa or bbbb.
  43.  
  44.       _B_N__s_u_b() subtracts bbbb from aaaa and places the result in rrrr
  45.       (r=a-b).
  46.  
  47.       _B_N__m_u_l() multiplies aaaa    and bbbb and places the result in rrrr
  48.       (r=a*b).  rrrr may be the same BBBBIIIIGGGGNNNNUUUUMMMM as    aaaa or bbbb.     For
  49.       multiplication by powers of 2, use BN_lshift(3).
  50.  
  51.       _B_N__d_i_v() divides aaaa by    dddd and places the result    in ddddvvvv and the
  52.       remainder in rrrreeeemmmm (dv=a/d, rem=a%d). Either of    ddddvvvv and rrrreeeemmmm may
  53.       be NULL, in which case the respective    value is not returned.
  54.       For division by powers of 2, use _B_N__r_s_h_i_f_t(3).
  55.  
  56.       _B_N__s_q_r() takes the square of aaaa and places the    result in rrrr
  57.       (r=a^2). rrrr and aaaa may be the same BBBBIIIIGGGGNNNNUUUUMMMM.  This function is
  58.       faster than _B_N__m_u_l(r,a,a).
  59.  
  60.  
  61.  
  62.  
  63.      Page 1                        (printed 11/10/00)
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.      BBBBNNNN____aaaadddddddd((((3333))))            22224444////FFFFeeeebbbb////2222000000000000    ((((0000....9999....6666))))             BBBBNNNN____aaaadddddddd((((3333))))
  71.  
  72.  
  73.  
  74.       _B_N__m_o_d() find    the remainder of aaaa divided by mmmm    and places it
  75.       in rrrreeeemmmm (rem=a%m).
  76.  
  77.       _B_N__m_o_d__m_u_l() multiplies aaaa by bbbb and finds the remainder when
  78.       divided by mmmm (r=(a*b)%m). rrrr may be the same BBBBIIIIGGGGNNNNUUUUMMMM as    aaaa or
  79.       bbbb. For a more    efficient algorithm, see
  80.       BN_mod_mul_montgomery(3); for    repeated computations using
  81.       the same modulus, see    BN_mod_mul_reciprocal(3).
  82.  
  83.       _B_N__e_x_p() raises aaaa to the pppp-th    power and places the result in
  84.       rrrr (r=a^p). This function is faster than repeated
  85.       applications of _B_N__m_u_l().
  86.  
  87.       _B_N__m_o_d__e_x_p() computes    aaaa to the pppp-th power modulo mmmm (r=a^p %
  88.       m). This function uses less time and space than _B_N__e_x_p().
  89.  
  90.       _B_N__g_c_d() computes the    greatest common    divisor    of aaaa and bbbb and
  91.       places the result in rrrr. rrrr may    be the same BBBBIIIIGGGGNNNNUUUUMMMM as aaaa    or bbbb.
  92.  
  93.       For all functions, ccccttttxxxx is a previously allocated BBBBNNNN____CCCCTTTTXXXX used
  94.       for temporary    variables; see BN_CTX_new(3).
  95.  
  96.       Unless noted otherwise, the result BBBBIIIIGGGGNNNNUUUUMMMM must be different
  97.       from the arguments.
  98.  
  99.      RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSS
  100.       For all functions, 1 is returned for success,    0 on error.
  101.       The return value should always be checked (e.g., if
  102.       (!BN_add(r,a,b)) goto    err;).    The error codes    can be
  103.       obtained by ERR_get_error(3).
  104.  
  105.      SSSSEEEEEEEE AAAALLLLSSSSOOOO
  106.       bn(3), err(3), BN_CTX_new(3),    BN_add_word(3),    BN_set_bit(3)
  107.  
  108.      HHHHIIIISSSSTTTTOOOORRRRYYYY
  109.       _B_N__a_d_d(), _B_N__s_u_b(), _B_N__d_i_v(),    _B_N__s_q_r(), _B_N__m_o_d(),
  110.       _B_N__m_o_d__m_u_l(),    _B_N__m_o_d__e_x_p() and _B_N__g_c_d() are available    in all
  111.       versions of SSLeay and OpenSSL. The ccccttttxxxx argument to _B_N__m_u_l()
  112.       was added in SSLeay 0.9.1b. _B_N__e_x_p() appeared    in SSLeay
  113.       0.9.0.
  114.  
  115.       BN_mod_exp, BN_gcd - arithmetic operations on    BIGNUMs"
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.      Page 2                        (printed 11/10/00)
  130.  
  131.  
  132.  
  133.